package com.whfc.iot.fse.crane.codec;

import com.whfc.iot.fse.crane.entity.TwConst;
import com.whfc.iot.fse.lift.codec.LiftMsgDataDecoderFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TwMsgDecoderFactory {
    private static Logger logger = LoggerFactory.getLogger(LiftMsgDataDecoderFactory.class);

    private static TwMsgDataCodecRealData twMsgDataCodecRealData = new TwMsgDataCodecRealData();
    private static TwMsgDataCodecWorkCycle twMsgDataCodecWorkCycle = new TwMsgDataCodecWorkCycle();
    private static TwMsgDataCodecParam twMsgDataCodecParam = new TwMsgDataCodecParam();

    public static TwMsgDataCodec getTwMsgDataCodec(Integer cmd) {
        TwMsgDataCodec bodyCodec = null;
        switch (cmd) {
            case TwConst.TW_CMD_REALDATA:
                bodyCodec = twMsgDataCodecRealData;
                break;
            case TwConst.TW_CMD_WORKCYCLEDATA:
                bodyCodec = twMsgDataCodecWorkCycle;
                break;
            case TwConst.TW_CMD_PARAM:
                bodyCodec = twMsgDataCodecParam;
                break;

            default:
                logger.info("无法解析的指令,cmd:{}", cmd);
                break;
        }
        return bodyCodec;
    }
}
